home *** CD-ROM | disk | FTP | other *** search
- Path: news.usa.net!earth!jhamp
- From: jhamp@earth.usa.net (James Hamp)
- Newsgroups: comp.lang.c
- Subject: newbie--what's wrong with this?
- Date: 27 Jan 1996 22:21:08 GMT
- Organization: Internet Express (800-592-1240 customer service)
- Message-ID: <4ee8gk$kes@shiva.usa.net>
- NNTP-Posting-Host: earth.usa.net
- X-Newsreader: TIN [version 1.2 PL2]
-
- As a new C programmer, I'm sure I'm being dumb, but I don't know what I
- did wrong.
-
- Basically, I have an array of structs called MESSAGERULES, which contain
- a pointer to a set of RULES to apply to a message, which in turn contain
- a pointer to COMPARERULES, with the whole object being to see if a message
- matches one of the RULES in the set by comparing it in turn to each of the
- COMPARERULES.
-
- In initializing these, I used the following code (not on this machine, so
- I can't use cut/paste--if you see any compile errors, they're typos.
-
-
- MSGRULE MsgRule[];
- RULE *Rule;
-
- /* Some initializations of MsgRule */
-
- MsgRule[offset].Rule = (RULE *)malloc(2 * sizeof(RULE));
-
- /* Some more inititalizations of MsgRule.Rule
-
- Rule = MsgRule[offset].Rule; /* Just to save typing--had to use this
- several times */
-
- Rule->CompRule = (COMPARERULE *)malloc(2 * sizeof(COMPARERULE));
-
- /* Initialize first compare rule, then... */
-
- Rule->CompRule++;
- ^^^^^^^^^^^^^^^^^ This didn't work--when I initialized the second rule
- (or so I thought), it went into the first rule.
-
- Thinking I had a precedence problem, I tried
-
- (Rule->CompRule)++;
-
- and the same thing happened.
- I know I'm being stupid here--my try that worked was
- to initialize the second rule with Rule->CompRule[1].members. Since I
- made it work, the code's okay, but I'd like to know what I'm not under-
- standing. Please e-mail responses--I don't get to this group as often
- as I'd like.
-
- advTHANKSance
- --Jim (The Hampster) Hamp
- |*************************************************************************|
- | So you ride yourselves over the fields |
- | And you make all your animal deals This space |
- | And your wise men don't know how it feels for rent. |
- | To be thick as a brick |
- | -Ian Anderson- The Hampster |
- | jhamp@usa.net |
- |*************************************************************************|
-